REM disklib.bas by John Kennan 10-21-86 CLEAR,20000 CLEAR,50000,5000 OPTION BASE 1 DIM prog$(1500),dir$(400),prog%(1500) dircheck=0:dircount=0:progcount=0 dname$="" DECLARE FUNCTION Execute& LIBRARY PRINT "For this program to work properly, Amigabasic must be started" PRINT "from the CLI! PRINT "If you have a one drive system, either boot on the DISKLIB:" PRINT "disk, or go to the CLI and type:" PRINT "`Execute Disklib:s/startup-sequence'" PRINT "If you have a two drive system, place Disklib: in the External Drive" PRINT "and use the internal drive to add disks to the library." WHILE ((drive<>1) AND (drive<>2)) INPUT;"Are you working on a one or two drive system (1 or 2):";drive WEND CLS IF drive=1 THEN CHDIR "Ram:" ELSE CHDIR "disklib:" LIBRARY "dos.library" x=Execute&(SADD("Assign c: disklib:c"+CHR$(0)), 0, 0) x=Execute&(SADD("Assign l: disklib:l"+CHR$(0)), 0, 0) x=Execute&(SADD("Assign devs: disklib:devs"+CHR$(0)), 0, 0) x=Execute&(SADD("Assign libs: disklib:libs"+CHR$(0)), 0, 0) x=Execute&(SADD("CD disklib:"+CHR$(0)), 0, 0) LIBRARY CLOSE END IF main: CLS PRINT "Library currently contains " progcount " programs (max 1500) and" PRINT dircount " directories (max 400)" PRINT "You have " FRE(1) "bytes of free memory in Basic" PRINT "Choose an option" PRINT "1-Add a Disk" PRINT "2-Sort by Directory" PRINT "3-Sort by Program" PRINT "4-Print Library to Screen" PRINT "5-Print Library to Printer" PRINT "6-Save Library to Disk" PRINT "7-Load Library from Disk" PRINT "8-Save Library as a Text File (for access from CLI)" PRINT "9-Delete a Directory" PRINT "10-Exit Program" choice=-1 WHILE ((choice>10) OR (choice<1)) INPUT;"Enter option 1-10:";choice WEND ON choice GOSUB adddisk,shellsort1,shellsort2,scprint,pprint,fsave,fload,textsave,dirdelete,exprog GOTO main adddisk: PRINT "Insert Disk to be added into DF0: and press 'C' to continue or 'A' to abort" a$="" WHILE ((a$<>"C") AND (a$<>"A")) a$=INKEY$ a$=UCASE$(a$) WEND IF a$="A" THEN RETURN CALL diskname(dname$) IF dname$="" THEN PRINT "NO DISK IN DRIVE!!" GOTO adddisk END IF dircheck=dircheck+1:dircount=dircount+1 dir$(dircheck)=dname$+":" flag=0 WHILE flag=0 CALL listram(dir$(dircheck)) OPEN "ram:temp" FOR INPUT AS #1 WHILE NOT EOF(1) LINE INPUT #1, temp$ IF (INSTR(temp$,"Directory")=0 AND INSTR(temp$," Dir ")) THEN IF (LEFT$(temp$,4)<>"Dir ") THEN IF (LEFT$(temp$,7)<>"MakeDir") THEN IF (INSTR(temp$,"directories")=0) THEN dircount=dircount+1 position=INSTR(temp$," ") newdir$=LEFT$(temp$,(position-1)) dir$(dircount)=dir$(dircheck)+newdir$+"/" IF newdir$="c" THEN dircount=dircount-1 IF newdir$="Trashcan" THEN dircount=dircount-1 IF newdir$="l" THEN dircount=dircount-1 IF newdir$="s" THEN dircount=dircount-1 IF newdir$="libs" THEN dircount=dircount-1 IF newdir$="fonts" THEN dircount=dircount-1 IF newdir$="devs" THEN dircount=dircount-1 END IF END IF END IF ELSE IF ((INSTR(temp$,"irectory")=0) AND (INSTR(temp$,"irectories")=0)) THEN IF ((INSTR(temp$,"ile -")=0) AND (INSTR(temp$,"iles -")=0)) THEN IF (INSTR(temp$,".info")=0) THEN progcount=progcount+1 prog%(progcount)=dircheck position=INSTR(temp$," ") prog$(progcount)=LEFT$(temp$,(position-1)) END IF END IF END IF END IF WEND CLOSE #1 KILL "ram:temp" PRINT "dircheck=" dircheck PRINT "dircount=" dircount dircheck=dircheck+1 IF dircheck>dircount THEN flag=1 WEND dircheck=dircount LIBRARY CLOSE RETURN scprint: n=1:m=0 WHILE n<= progcount WHILE m<20 IF n<=progcount THEN PRINT prog$(n) TAB(30) dir$(prog%(n)) n=n+1:m=m+1 WEND m=0 PRINT "To Continue hit 'C' (or 'A' to abort)" a$="" WHILE ((a$<>"C") AND (a$<>"A")) a$=INKEY$ a$=UCASE$(a$) WEND IF a$="A" THEN n=progcount+1 WEND RETURN pprint: GOSUB setprt FOR n=1 TO progcount LPRINT prog$(n) TAB(30) dir$(prog%(n)) NEXT n RETURN textsave: PRINT "If you are using a one drive system" PRINT "Filename must include the drive specifier (ie. DF0:)" PRINT "or the disk NAME, or the file will be saved TO Ram:" INPUT;"Input file name to be SAVED (enter 'A' to abort)";a$ a$=UCASE$(a$) IF a$="A" THEN RETURN b$="" IF (drive=1) AND (INSTR(a$,CHR$(58))=0) THEN PRINT "You did not include the drive or disk name!!" INPUT;"Do you want to save to df0: or abort (S or A)?:";b$ b$=UCASE$(b$) IF b$="S" THEN a$="df0:"+a$ END IF IF b$="A" THEN RETURN OPEN a$ FOR OUTPUT AS #1 FOR n=1 TO progcount PRINT #1,prog$(n) "\\" dir$(prog%(n)) NEXT n CLOSE #1 RETURN fsave: PRINT "If you are using a one drive system" PRINT "Filename must include the drive specifier (ie. DF0:)" PRINT "or the disk NAME, or the file will be saved TO Ram:" INPUT;"Input file name to be SAVED (enter 'A' to abort)";a$ a$=UCASE$(a$) IF a$="A" THEN RETURN b$="" IF (drive=1) AND (INSTR(a$,CHR$(58))=0) THEN PRINT "You did not include the drive or disk name!!" INPUT;"Do you want to save to df0: or abort (S or A)?:";b$ b$=UCASE$(b$) IF b$="S" THEN a$="df0:"+a$ END IF IF b$="A" THEN RETURN OPEN a$ FOR OUTPUT AS #1 PRINT #1,dircount;progcount FOR n=1 TO dircount WRITE #1, dir$(n) NEXT n FOR n=1 TO progcount WRITE #1,prog$(n),prog%(n) NEXT n CLOSE #1 RETURN fload: ON ERROR GOTO 0 PRINT "Filename must include the drive specifier (ie. DF0:)" PRINT "or the disk NAME, or the file will be loaded from Ram:" INPUT;"Input file name to be LOADED (enter 'A' to abort)";a$ a$=UCASE$(a$) IF a$="A" THEN RETURN ON ERROR GOTO diskerror OPEN a$ FOR INPUT AS #1 ON ERROR GOTO 0 INPUT #1,dircount,progcount FOR n=1 TO dircount INPUT #1, dir$(n) NEXT n FOR n=1 TO progcount INPUT #1,prog$(n),prog%(n) NEXT n dircheck=dircount CLOSE #1 RETURN diskerror: PRINT "FILE NOT FOUND!!":PRINT RESUME fload shellsort1: PRINT "Sorting...." s=2^INT(LOG(progcount)/LOG(2)) IF s<(progcount/2) THEN s=s*2 startsort: s=INT(s/2) IF s=0 THEN RETURN FOR t=1 TO progcount-s y=t L1: w=y+s IF UCASE$(dir$(prog%(y)))<=UCASE$(dir$(prog%(w))) THEN GOTO Skip1 SWAP prog%(y),prog%(w) SWAP prog$(y),prog$(w) y=y-s IF y>0 THEN GOTO L1: Skip1: NEXT t GOTO startsort shellsort2: PRINT "Sorting..." s=2^INT(LOG(progcount)/LOG(2)) IF s<(progcount/2) THEN s=s*2 startsort2: s=INT(s/2) IF s=0 THEN RETURN FOR t=1 TO progcount-s y=t L2: w=y+s IF UCASE$(prog$(y))<=UCASE$(prog$(w)) THEN GOTO Skip2 SWAP prog%(y),prog%(w) SWAP prog$(y),prog$(w) y=y-s IF y>0 THEN GOTO L2: Skip2: NEXT t GOTO startsort2 SUB listram(currentdir$) STATIC LIBRARY "dos.library" x=Execute&(SADD("list >RAM:temp "+CHR$(34)+currentdir$+CHR$(34)+CHR$(0)), 0, 0) LIBRARY CLOSE END SUB SUB diskname (dname$) STATIC LIBRARY "dos.library" x=Execute&(SADD("info >RAM:temp"+CHR$(0)), 0, 0) OPEN "RAM:temp" FOR INPUT AS #1 position=0 WHILE position=0 LINE INPUT #1,a$ position=INSTR(a$,"Name") WEND string=0 WHILE string=0 LINE INPUT #1,a$ string=INSTR(a$,"DF0:") WEND IF INSTR(a$,"No disk present")<>0 THEN dname$="" ELSE dname$=RIGHT$(a$,LEN(a$)-position+1) END IF CLOSE #1 KILL "RAM:temp" LIBRARY CLOSE END SUB setprt: OPEN "prt:" FOR OUTPUT AS #1 PRINT #1,CHR$(27);"c"; PRINT #1,CHR$(27);"[66t"; PRINT #1,CHR$(27);"[12q"; CLOSE #1 RETURN dirdelete: INPUT;"Input Directory name to be deleted (enter 'A' to abort)";dirdel$ dirdel$=UCASE$(dirdel$) IF dirdel$="A" THEN RETURN zz=dircount FOR n=zz TO 1 STEP -1 IF INSTR(dir$(n),dirdel$)<>0 THEN GOSUB ddelete NEXT n dircheck=dircount RETURN ddelete: PRINT "Delete" dir$(n) "?(Y or N):":INPUT a$ a$=UCASE$(a$) IF a$<>"Y" THEN RETURN FOR m=n TO dircount-1 dir$(m)=dir$(m+1) NEXT m dircount=dircount-1 m=1 WHILE m<=progcount IF prog%(m)=n THEN FOR z=m TO progcount-1 prog%(z)=prog%(z+1) prog$(z)=prog$(z+1) NEXT z progcount=progcount-1 END IF IF prog%(m)>n THEN prog%(m)=prog%(m)-1 IF prog%(m)<>n THEN m=m+1 WEND RETURN exprog: LIBRARY CLOSE CLOSE #1 CHDIR "Disklib:" IF drive=2 THEN LIBRARY "dos.library" x=Execute&(SADD("Assign c: sys:c"+CHR$(0)), 0, 0) x=Execute&(SADD("Assign l: sys:l"+CHR$(0)), 0, 0) x=Execute&(SADD("Assign devs: sys:devs"+CHR$(0)), 0, 0) x=Execute&(SADD("Assign libs: sys:libs"+CHR$(0)), 0, 0) LIBRARY CLOSE ELSE PRINT "To restore system to its condition before you ran the program" PRINT "Go to the CLI and type `Execute disklib:s/end-sequence'" END IF END